package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.Inventory;
import com.ymttest.utils.EnvSetup;

/************************************************************************************
 * @File name : InventoryWapper.java
 * @Author : sunsheng
 * @Date : 2015年8月20日
 * @Copyright : 洋码头
 ************************************************************************************/
public class InventoryWapper {
	SqlManager manage;

	public InventoryWapper() {
		manage = new SqlManager("xlobo" + EnvSetup.getEnv());
	}

	/**
	 * 根据userid查询inventory表信息
	 * 
	 * @param userid
	 * @return List<Inventory>
	 * @throws InterruptedException
	 */
	public List<Inventory> getInventoryInfoByUserid(String userid) throws InterruptedException {
		Map<String, String> map = new HashMap<String, String>();
		map.put("userid", userid);
		Thread.sleep(1000);
		List<Inventory> InventoryList = manage.getSelectResults(
				"com.ymttest.database.mapping.InventoryMapper.selectByuserid", map);
		// manage.close();
		return InventoryList;
	}

	/**
	 * 查询amountavailable>5 的前10条inventory表信息
	 * 
	 * @param null
	 * @return List<Inventory>
	 * @throws InterruptedException
	 */
	public List<Inventory> getTop10InventoryInfo() throws InterruptedException {
		List<Inventory> InventoryList = manage.getSelectResults(
				"com.ymttest.database.mapping.InventoryMapper.selectTop10", null);
		// manage.close();
		return InventoryList;
	}

	public static void main(String[] args) {
		try {
			Logger.debug(new InventoryWapper().getTop10InventoryInfo());
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}

}
